﻿@{
    ViewBag.Title = "RptBuyRank";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
<body>
    <form id="form1" runat="server" method="post" style="height: 100%">

        @Html.Partial("~/Views/Modular/ReportsToolbar.cshtml")

        <div id="DivHeader">
            <table style="margin-bottom:4px;">
                <tr>
                    <td width="70px" align="right">消费日期：</td>
                    <td width="310px">
                        @Html.Partial("~/Views/Modular/dxDateRange.cshtml")
                    </td>
                    <td width="70px" align="right">分店名称：</td>
                    <td width="200px">
                        @Html.Partial("~/Views/Modular/LookupCorpInfo.cshtml")
                    </td>
                </tr>
            </table>
        </div>
        <div class="mini-fit">
            <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:1;" pageSize="15"
                 url="../Member/GetContribution"
                 allowCellSelect="true" allowCellEdit="true" showSummaryRow="false" fitColumns="false">
                <div property="columns">
                    <div type="checkcolumn"></div>
                    <div field="FName" width="130" headerAlign="center">会员类型</div>
                    <div field="FMemberQty" name="FMemberQty" width="80" headerAlign="center" align="right" numberFormat="#">会员数</div>
                    <div field="FMemberRatio" name="FMemberRatio" width="90" headerAlign="center" align="right" numberFormat="p">会员占比</div>
                    <div field="FConsumeQty" name="FConsumeQty" width="80" headerAlign="center" align="right" numberFormat="#">消费会员数</div>
                    <div field="FConsumeRatio" name="FConsumeRatio" width="100" headerAlign="center" align="right" numberFormat="p">消费会员占比</div>
                    <div field="FAverageQty" name="FAverageQty" width="100" headerAlign="center" align="right" numberFormat="p">消费会员比率</div>
                    <div field="FOrderQty" name="FOrderQty" width="100" headerAlign="center" align="right" numberFormat="#,0.00">消费订单数</div>
                    <div field="FOrderPrice" name="FOrderPrice" width="100" headerAlign="center" align="right" numberFormat="#,0.00">客单均价(元)</div>
                    <div field="FOrderAmount" name="FOrderAmount" width="100" headerAlign="center" align="right" numberFormat="#,0.00">消费金额(元)</div>
                    <div field="FOrderRatio" name="FOrderRatio" width="100" headerAlign="center" align="right" numberFormat="p">消费金额占比</div>                 
                </div>
            </div>
        </div>

    <div>
        <table>
            <tr>
                <td width ="40px" align="right">说明：</td>
                <td align="left">
                    会员占比=会员数/会员数合计；消费会员占比=消费会员数/消费会员数合计；消费会员比率=消费会员数/会员数；消费金额占比=消费金额/消费金额合计
                </td>
            </tr>
        </table>
    </div>

        <script type="text/javascript">

        mini.parse();
        var form = new mini.Form("form1");
        var grid = mini.get("datagrid1");
        var uID = parent.window.getSystemAppID();
        var sumFields = "";

        function FormShown() {
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            LoadData();
        }

        function clearloca() {
            mini.getbyName("FCorpItemID").setValue("");
            mini.getbyName("FCorpItemID").setText("");
            mini.getbyName("FCorpName").setValue("");
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            mini.getbyName("comdatasel").setValue(0);
        }

        function LoadData() {
            var cDate1 = mini.getbyName("FDate1").getFormValue();
            var cDate2 = mini.getbyName("FDate2").getFormValue();
            var mFCorpID = mini.getbyName("FCorpItemID").getValue();

            var json = "[{";
            json = json + '"mReportType":' + '"6001",';//列表类型
            json = json + '"mSystemAppID":' + '"' + uID + '",';
            json = json + '"mDate1":' + '"' + cDate1 + '",';
            json = json + '"mDate2":' + '"' + cDate2 + '",';
            json = json + '"mFCorpID":' + '"' + mFCorpID + '"';
            json = json + "}]";

            grid.load({ mydata: json });

            mExportDataUrl = grid.url;
            mExportDataJson = json;//导出
        }

        function printdata() {
            var url = "../Report/PrintReport";
            mini.open({
                url: url,
                title: "打印", width: 1000, height: 700,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var NoneDisplayCol = [0];
                    iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, parent.window.getSystemCompany() + "会员消费排行表");
                }
            });
        }

        </script>

    </form>
</body>